﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Extensions.DependencyInjection;

namespace AirCtrl.Wpf.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : UserControl
    {
        private MainViewModel _vm;
        public MainView()
        {
            InitializeComponent();

            _vm = App.Current.ServiceProvider.GetRequiredService<MainViewModel>();
            DataContext = _vm;

            
        }

        private void List_OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            _vm.CameraWidth = e.NewSize.Width / _vm.RowCameraCount - 20;
            _vm.CameraHeight = e.NewSize.Height / (Math.Ceiling(_vm.CameraVms.Count / _vm.RowCameraCount)) - 20;
        }

    }
}
